<template>
  <div id="temp">
    <mt-header fixed title="评论撰文"></mt-header>
    <!--1.首页-->
    <div id="show">
      <div class="title">
        <h4 v-text="news.title"></h4>
        <span v-text="news.add_time"></span>
        <span>{{news.click}}次浏览</span>
      </div>
      <div class="content" v-html="news.content">
      </div>

      <!--评论组件-->
      <comment :id="id"></comment>
    </div>
  </div>
</template>

<script>
  import {Toast} from 'mint-ui';
  import kit  from '../../kits/apikit'
  // 1.0导入评论组件 comment.vue
  import comment from '../subcom/comment.vue'
  export default{
    components:{
      //          comment:comment
      comment
    },

    data(){
      return {
        id: 0,
        //对象格式的数据
        news:{}
      }
    },
    created()
    {
//			1.0 获取url传入的id参数值赋值给data中的id属性
      this.id = this.$route.params.id;
//            2.0 请求服务器获取到这个id对应的详情数据对象
      this.getNews();
    },
    methods:{
      getNews(){
        var url = kit.apikit+'type=getnew&newid='+this.id;
        this.$http.get(url).then(function (response) {
          if(response.body.status!=0){
            Toast(response.body.message);
            return;
          }
          this.news = response.body.message;
        })
      }
    }
  }
</script>
<style scoped>
  /*1.首页改颜色*/
  .title p{
    color:rgba(0,0,0,0.5);
  }
  .title,#content{
    padding: 5px;
  }

</style>
